package org.xbzheng.boot.bean;

import com.fasterxml.jackson.annotation.JsonInclude;
import org.springframework.http.HttpStatus;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class Result {
    private HttpStatus status;
    private boolean success;
    private String message;
    private Object data;

    public Result(boolean success, HttpStatus status, Object data) {
        this.success = success;
        this.status = status;
        this.data = data;
    }

    public Result(HttpStatus status, String message) {
        this.status = status;
        this.message = message;
    }

    public Result(HttpStatus status, boolean success, String message, Object data) {
        this.status = status;
        this.success = success;
        this.message = message;
        this.data = data;
    }

    public HttpStatus getStatus() {
        return status;
    }

    public void setStatus(HttpStatus status) {
        this.status = status;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static Result ok(){
        return ok(null);
    }

    public static Result ok(Object data){
        return new Result(true, HttpStatus.OK, data);
    }

    public static Result error(){
        return error(HttpStatus.OK, "");
    }

    public static Result error(HttpStatus status, String message){
        return new Result(status, message);
    }
}
